package com.hrsaas.ext.spider.test.domain;

import java.util.Map;

import com.hrsaas.ext.spider.test.handler.LGCoreResumeHandler;

/**
 * @author wangxiaoliang
 * 上下文切换
 */
public class Context {

	private LGCoreResumeHandler handler;
	
	private Map<String, String> selectedArgs;
	
	private String url;
	
	private Step step;
	
	public LGCoreResumeHandler getHandler() {
		return handler;
	}

	public Map<String, String> getSelectedArgs() {
		return selectedArgs;
	}

	public void setSelectedArgs(Map<String, String> selectedArgs) {
		this.selectedArgs = selectedArgs;
	}

	public Step getStep() {
		return step;
	}

	public void setStep(Step step) {
		this.step = step;
	}
	
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public void setHandler(LGCoreResumeHandler handler) {
		this.handler = handler;
	}

	/**
	 * 恢复执行
	 * @param key
	 */
	public void recovery() {
		final Integer code = step.code;
		switch (code) {
			case 0: handler.resumelist(selectedArgs);
				break;
			case 1: handler.downloadResume(url);
				break;
		}
	}
	
	public enum Step {
		
	    LIST(0,"list"),
	    DOWNLOAD(1,"download")
	    ;

	    private Integer code;
	    private String name;

	    Step(Integer code,String name) {
	        this.code = code;
	        this.name= name;
	    }

	    public int getCode() {
		    return code;
	    }
	    
	    public String getName() {
		    return name;
	    }		
		
	}

}
